﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1.Work4
{
    class work42
    {
        static void Main()
        {
            Random rand = new Random();
            int[] numbers = Enumerable.Range(0, 100)
                                      .Select(_ => rand.Next(0, 1001))
                                      .ToArray();

          
            var sortedDesc = numbers.OrderByDescending(n => n);

            int sum = numbers.Sum();
            double average = numbers.Average();

            // 4. 输出结果
            Console.WriteLine("原始数列：");
            Console.WriteLine(string.Join(", ", numbers));
            Console.WriteLine("\n从大到小排序后：");
            Console.WriteLine(string.Join(", ", sortedDesc));

            Console.WriteLine($"\n总和 = {sum}");
            Console.WriteLine($"平均值 = {average:F2}");
        }
    }
}
